package com.power.using.mydaggerp.base;

import android.support.annotation.NonNull;

import com.zyw.horrarndoo.sdk.RxManager;

/**
 * Created by 聪明一只哈 on 2019/10/10.
 * Time: 2019/10/10  16:48
 */
public abstract class BasePresenter<M,V> {

    protected M mIModel;
    protected V mIView;
    protected RxManager mRxManage=new RxManager();

    /**
     * 返回presenter想持有的Model引用
     *
     * @return presenter持有的Model引用
     */
    protected abstract M getModel();


    public void attachMV(@NonNull V v){
        this.mIModel=getModel();
        this.mIView=v;
        this.onStart();
    }


    public void detachMV(){
        mRxManage.unSubscribe();
        mIView=null;
        mIModel=null;

    }


    /**
     * IView和IModel绑定完成立即执行
     * <p>
     * 实现类实现绑定完成后的逻辑,例如数据初始化等,界面初始化, 更新等
     */
    public abstract void onStart();


}
